$(".reduce").click(function () {
    var count = $(".count").text()
    if (count == 1)
        $(".reduce").attr("disable","true")
    else{
        count = parseInt(count)-1;
        $(".count").text(count)
    }
})
$(".addcount").click(function () {
    var count = $(".count").text()
    $(".count").text(parseInt(count)+1)
})
var proId = 1;
$.ajax({
    type:"get",
    url:"/fresh/getSpec?proId="+proId,
    datatype:"json",
    success:function (result) {
        console.log(result);
        if (result.status == 1){
            var time = getFullDate(result.data.specTime)
            $(".time").text(time)
        }
    }
})
function getFullDate(ms){
    var d = new Date(ms);
    var year = d.getFullYear();
    var month = d.getMonth()+1;
    var day = d.getDate();
    return year+"-" + month + "-" + day;

}


$(".addToCart").click(function () {
   var proId = $("#proId").text();
   var seckillId = $("#seckillId").text();
    console.log(seckillId);
    console.log(proId);
    $.ajax({
       type: "post",
       url: "/fresh/seckill/rob",
       data:"seckillId="+seckillId,
       datatype: "json",
       success:function (result) {
           if (result.code==0){
               alert("恭喜你，抢到商品快去下单吧！")
               $.ajax({
                   type: "post",
                   url: "/fresh/seckill/addcart",
                   data:"proId="+proId,
                   datatype: "json",
                   success:function (result) {
                       console.log(result);
                   }
               })
           } else {
               alert(result.message)
           }
       }
   })


})
